package mock.servicesdirectory.geography.web.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import mock.servicesdirectory.common.entities.Country;
import mock.servicesdirectory.geography.business.businessinterface.CountryBo;

import com.opensymphony.xwork2.ActionSupport;

public class CountryAction extends ActionSupport {
	CountryBo countryBo;
	private List<Country> countryList;
	private List<String> countryListName=new ArrayList<String>();
	private Map<Integer,String> countryMap=new HashMap<Integer, String>();
	public CountryBo getCountryBo() {
		return countryBo;
	}

	public void setCountryBo(CountryBo countryBo) {
		this.countryBo = countryBo;
	}

	public void setCountryList(List<Country> countryList) {
		this.countryList = countryList;
	}

	public List<Country> getCountryList() {
		return countryList;
	}

	@Override
	public String execute() throws Exception {
		countryList=countryBo.listCountry();
		/*for(Country country:countryList){
			countryListName.add(country.getCountryName());
		}*/
		for(Country country:countryList){
			countryMap.put(country.getCountryId(), country.getCountryName());
		}
		return SUCCESS;
	}
	


	/*public String getJSON() throws Exception{
	    	return execute();
	    }*/

	public void setCountryListName(List<String> countryListName) {
		this.countryListName = countryListName;
	}

	public List<String> getCountryListName() {
		return countryListName;
	}

	public void setCountryMap(Map<Integer,String> countryMap) {
		this.countryMap = countryMap;
	}

	public Map<Integer,String> getCountryMap() {
		return countryMap;
	}
	
	
}
